using System;
using System.Collections.Generic;
using System.Text;
using Krile.Imported.Snippets;

namespace Krile
{
    /// <summary>
    /// System Global Values
    /// </summary>
    static class Define
    {
        //"const" is a static value in all release.
        //but,if it needed to change,you can change this prop.
        //"readonly" is a variable value in all release.
        //this prop can change whenever.

        #region Release Versioning

        /// <summary>
        /// Version No.(X.XX)
        /// </summary>
        public static readonly double Version = 1.2;

        /// <summary>
        /// Version Suffix
        /// </summary>
        public static readonly string Suffix = " final";

        /// <summary>
        /// Build No.
        /// </summary>
        public static readonly int Build = 530;

        #endregion

        #region System Base Values

        /// <summary>
        /// Application Name
        /// </summary>
        public const string ApplicationName = "Krile";

        /// <summary>
        /// Project Name
        /// </summary>
        public const string ProjectName = "Fairytale";

        #endregion

        #region Common Values

        #region Directory Or File Names

        /// <summary>
        /// Splash Screen Configuration Flag File
        /// </summary>
        public const string SplashConfigFileName = ".splash";

        /// <summary>
        /// Plugin Directory Name
        /// </summary>
        public const string PluginDir = "plugins";

        /// <summary>
        /// Resource Directory Name
        /// </summary>
        public const string ResourceDir = "resources";

#if PURE_CLR
        /// <summary>
        /// Configuration File Name
        /// </summary>
        public const string ConfigFileName = ".krile";

        /// <summary>
        /// State File Name
        /// </summary>
        public const string StateFileName = ".local";
#else
        /// <summary>
        /// Configuration File Name
        /// </summary>
        public const string ConfigFileName = "krile.xml";

        /// <summary>
        /// Configuration File Name
        /// </summary>
        public const string ConfigBackupFileName = "$krile.xml";

        /// <summary>
        /// State File Name
        /// </summary>
        public const string StateFileName = "krile.state";

        /// <summary>
        /// State File Name
        /// </summary>
        public const string StateBackupFileName = "$krile.state";

        /// <summary>
        /// Dynamic information file
        /// </summary>
        public const string DynamicInformationFileName = "krile.dynamic";

        /// <summary>
        /// Dynamic information file
        /// </summary>
        public const string DynamicInformationBackupFileName = "$krile.dynamic";

#endif
        /// <summary>
        /// Debugger Output File Name
        /// </summary>
        public const string DebugReportFileName = "report.dbg";

        /// <summary>
        /// Auto-start agent file name
        /// </summary>
        public const string DebugAgentFileName = "kage.exe";

        /// <summary>
        /// Application updater name
        /// </summary>
        public const string UpdateExeName = "kup.exe";

        /// <summary>
        /// Image cache directory name
        /// </summary>
        public const string ImageCacheDirName = "krile_imgc";

        #endregion

        #region String Literal

        /// <summary>
        /// Crypto Key
        /// </summary>
        public const string CryptoKey = "Vm0xNGIyUXhVWGhVV0d4VllUSm9WVmxVU205WFJscHhVMnhPVjAxV1NsbFVWbU0xWVRBeFdHVkdXbFpOYWxaUVdXdGtTMVpzWkhKaVJuQm9UVzFvVlZacVNqUldNVnBXVFZWV2FHVnFRVGs9";

        /// <summary>
        /// Default Plugin Identificaion String
        /// </summary>
        public const string DefaultPluginId = ".!ID_Krile_DEFAULT";

        /// <summary>
        /// 1st Distributing Site URI
        /// </summary>
        public static readonly string DistUri = "http://starwing.net";

        /// <summary>
        /// Update Data Download From This URI
        /// </summary>
        public static readonly string UpdateUri = "http://update.starwing.net/krile";

        /// <summary>
        /// Updater URI
        /// </summary>
        public static readonly string UpdaterExeUri = "http://update.starwing.net/ku/kup.exe";

        /// <summary>
        /// On-line help URI
        /// </summary>
        public static readonly string OnlineHelpUri = "http://krile.starwing.net/";

        #endregion

        #region Magic Numbers

        public const int ReportSendLength = 1024 * 10;

        #endregion

        #endregion

        #region Global Semi-Readonly Values

        private static string apppath;
        /// <summary>
        /// Application Startup Path
        /// </summary>
        public static string AppPath
        {
            get { return apppath; }
            internal set
            {
                if (apppath != null)
                    throw new FieldAccessException("Define.AppPath can't set.");
                apppath = value;
            }
        }

        private static bool unsupported = false;
        /// <summary>
        /// Unsupported system
        /// </summary>
        public static bool Unsupported
        {
            get { return unsupported; }
            set
            {
                if (!value)
                    throw new FieldAccessException("Define.Unsupported can't set value \"false\".");
                unsupported = value;
            }
        }

        private static int firstboot = -1;
        /// <summary>
        /// Application Firstboot Flag
        /// </summary>
        public static bool FirstBoot
        {
            get { return firstboot == 1; }
            set
            {
                if (firstboot != -1)
                    throw new FieldAccessException("Define.FirstBoot can't set.");
                if (value)
                    firstboot = 1;
                else
                    firstboot = 0;
            }
        }

        /// <summary>
        /// Image caching directory
        /// </summary>
        public static readonly string ImgCacheDir = Cores.ImageManager.GetTemporaryDir();

        #endregion

        #region ValueFormatters

        /// <summary>
        /// Version Formatter
        /// </summary>
        public static string VersionString
        {
#if PURE_CLR
            get { return Version.ToRoundDown(2).ToString("0.00") + "NP" + Suffix; }
#else
            get { return Version.ToRoundDown(2).ToString("0.00") + Suffix; }
#endif
        }

        /// <summary>
        /// Application Infomation Formatter
        /// </summary>
        public static string AppInfoString
        {
            get { return ApplicationName + " " + VersionString; }
        }

        /// <summary>
        /// Application Infomation Full Formatter
        /// </summary>
        public static string AppInfoFullString
        {
            get { return AppInfoString + "(build:" + Build + ")"; }
        }

        /// <summary>
        /// User Agent Formatter
        /// </summary>
        public static string UserAgent
        {
            get { return ApplicationName + "/" + ProjectName + " " + Version.ToRoundDown(2).ToString("0.000") + "." + Build.ToString("0000") + "(.NET Framework " + Environment.Version.ToString() + ")"; }
        }
        #endregion
    }
}
